package com.ruoyi.service.impl;

import com.ruoyi.domain.vo.BehaviorPunchingRecordVo;
import com.ruoyi.domain.vo.BehaviorRecodeVo;
import com.ruoyi.domain.vo.BehaviorVo;
import com.ruoyi.domain.vo.BehaviorsCo2ReductionVo;
import com.ruoyi.mapper.LowCarbonBehaviorMapper;
import com.ruoyi.service.ILowCarbonBehaviorService;
import com.ruoyi.system.domain.Behavior;
import com.ruoyi.system.domain.BehaviorRecode;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.time.LocalDate;
import java.util.Date;
import java.util.List;

@Service
public class LowCarbonBehaviorServiceImpl implements ILowCarbonBehaviorService {
    @Autowired
    private LowCarbonBehaviorMapper lowCarbonBehaviorMapper;

    @Override
    public List<BehaviorsCo2ReductionVo> getBehaviorsCo2Reduction(Long UserId){
        return lowCarbonBehaviorMapper.getBehaviorsCo2Reduction(UserId);
    }

    /**
     *  添加低碳行为和记录
     */
//    @Override
//    public int insertLowCarbonBehavior(BehaviorVo behavior) {
//        return lowCarbonBehaviorMapper.insertLowCarbonBehavior(behavior);
//    }
    @Override
    public void behaviorPunchCard(BehaviorPunchingRecordVo behaviorPunchingRecordVo) {
        lowCarbonBehaviorMapper.behaviorPunchCard(behaviorPunchingRecordVo);
        // 更新用户的减碳量
        lowCarbonBehaviorMapper.updateUserCo2Reduction(behaviorPunchingRecordVo);
    }
    @Override
    public Double getReduceCo2Today(Long userId, Long behaviorCode, LocalDate today) {
        return lowCarbonBehaviorMapper.getReduceCo2Today(userId, behaviorCode, today);
    }

    @Override
    public Double getReduceCo2LimitationByBehaviorCode(Long behaviorCode) {
        return lowCarbonBehaviorMapper.getReduceCo2LimitationByBehaviorCode(behaviorCode);
    }

    @Override
    public Double getReduceCo2ByBehaviorValue(Double behaviorValue, Long behaviorCode){
        return lowCarbonBehaviorMapper.getReduceCo2ByBehaviorValue(behaviorValue, behaviorCode);
    }

    @Override
    public void behaviorPunchCardSub(BehaviorPunchingRecordVo behaviorPunchingRecordVo, Double reduceCo2){
        lowCarbonBehaviorMapper.behaviorPunchCardSub(behaviorPunchingRecordVo, reduceCo2);
        // 更新用户的减碳量
        lowCarbonBehaviorMapper.updateUserCo2ReductionSub(behaviorPunchingRecordVo, reduceCo2);
    }

    @Override
    public List<BehaviorVo> getLowCarbonBehaviorList() {
        return lowCarbonBehaviorMapper.getLowCarbonBehaviorList();
    }
//
//    @Override
//    public int BehaviorPunchCard(BehaviorRecode behaviorRecode) {
//        return lowCarbonBehaviorMapper.BehaviorPunchCard(behaviorRecode);
//    }
//
//    @Override
//    public Long getBehaviorCodeByName(String behaviorName) {
//        return lowCarbonBehaviorMapper.getBehaviorCodeByName(behaviorName);
//    }

//    @Override
//    public String getBehaviorTypeIdByType(String behaviorType) {
//        return lowCarbonBehaviorMapper.getBehaviorTypeIdByType(behaviorType);
//    }
    @Override
    public Double getConversionRateByBehaviorCode(Long behaviorCode){
        return lowCarbonBehaviorMapper.getConversionRateByBehaviorCode(behaviorCode);
    }
}
